<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <title>个人信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="__HOME_CSS__/font.css">
    <link rel="stylesheet" href="__HOME_CSS__/xadmin.css">
    <script src="__HOME_JS__/echarts.min.js"></script>
    <script src="__HOME_LIB__/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="__HOME_JS__/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="__HOME_JS__/html5.min.js"></script>
    <script src="__HOME_JS__/respond.min.js"></script>
    <![endif]-->
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form">
            {:token()}
            <div class="layui-form-item">
                <label for="L_username" class="layui-form-label">登录名</label>
                <div class="layui-input-inline">
                    <input type="text" id="L_username" value="{$row.username}" readonly="readonly"
                           autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">不可修改</div>
            </div>
            <div class="layui-form-item">
                <label for="L_nickname" class="layui-form-label"><span class="x-red">*</span>昵称</label>
                <div class="layui-input-inline">
                    <input type="text" id="nickname" name="nickname" lay-verify="required" value="{$row.nickname}"
                           autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="mobile" class="layui-form-label">手机</label>
                <div class="layui-input-inline">
                    <input type="text" id="mobile" name="mobile" value="{$row.mobile}" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">可用做登录名</div>
            </div>
            <div class="layui-form-item">
                <label for="pass" class="layui-form-label">密码</label>
                <div class="layui-input-inline">
                    <input type="password" id="pass" name="pass" placeholder="留空则不修改" required="" lay-verify="pass"
                           autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    6到16个字符
                </div>
            </div>
            <div class="layui-form-item">
                <label for="repass" class="layui-form-label">
                    <span class="x-red">*</span>确认密码
                </label>
                <div class="layui-input-inline">
                    <input type="password" id="repass" name="repass" required="" lay-verify="repass"
                           autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="repass" class="layui-form-label">
                </label>
                <button  class="layui-btn" lay-filter="add" lay-submit="">
                    确认增加
                </button>
            </div>
        </form>
    </div>
</div>
<script>layui.use(['form', 'layer'],
    function() {
        $ = layui.jquery;
        var form = layui.form,
            layer = layui.layer;

        //自定义验证规则
        form.verify({
            repass: function(value) {
                if ($('#pass').val() && ($('#pass').val() !== $('#repass').val())) {
                    return '两次密码不一致';
                }
            }
        });

        //监听提交
        form.on('submit(add)',
            function(data) {
                var nickname = data.field.nickname;
                var pass = data.field.pass;
                var mobile = data.field.mobile;
                var token = data.field.__token__;
                $.ajax({
                    type: 'post',
                    url: "{:url('index/admin/profile?id='.$row.id)}",
                    sync:false,
                    data: {
                        nickname: nickname,
                        mobile: mobile,
                        password: pass,
                        token:token,
                    },
                    success: function (res) {
                        if (res.code === 0) {
                            layer.msg(res.msg, {
                                    icon: 6
                                },
                                function () {
                                    xadmin.close();
                                    xadmin.father_reload();
                                });

                        } else {
                            layer.msg(res.msg)
                        }
                    }
                });
                return false;
            });

    });</script>
</body>

</html>